pluginHome = new File( grailsSettings.projectPluginsDir.path ).listFiles().find { it.name.startsWith('cloud-tools-') }
if(pluginHome == null) pluginHome = "."

includeTargets << new File( "${pluginHome}/scripts/CloudToolsInit.groovy" )

target('default': "Enales the BRB Page") {
	enableBrb()
}

target(enableBrb: "The implementation task") {
	depends( initCloudToolsService)
    cloudToolsService.withCluster { clusterManager, clusterName, cluster ->
		if(System.getProperty("cloudtools.brb.page") != null){
			def brbPage = System.getProperty("cloudtools.brb.page")
			cluster.getClusterInstance().getWebServerTier().enableBrb(brbPage);
			event('StatusFinal', ['Done enabling brb page: ' + brbPage])
		}else{
			event('StatusError', ['You did not specify a brb page.  Example:\ngrails -Dcloudtools.brb.page=<brb page> cloud-tools-enable-brb'])
		}
	}
}
